package com.breaking.second.utils.compat;

import androidx.annotation.NonNull;

import com.alibaba.fastjson2.JSONArray;
import com.breaking.second.application.EscortApplication;
import com.breaking.second.entity.PageableVo;
import com.scwang.smart.refresh.footer.ClassicsFooter;
import com.scwang.smart.refresh.header.ClassicsHeader;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.listener.OnLoadMoreListener;
import com.scwang.smart.refresh.layout.listener.OnRefreshListener;

public class RefreshLayoutCompat {
    public static void setRefresh(PageableVo pageableVo, RefreshLayout smart, OnRefreshListener refreshListener) {
        smart.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(@NonNull RefreshLayout refreshLayout) {
                pageableVo.setCurrent(0);
                refreshListener.onRefresh(refreshLayout);
                refreshLayout.setNoMoreData(true);
            }
        });
        smart.setOnLoadMoreListener(new OnLoadMoreListener() {
            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
                pageableVo.setCurrent(pageableVo.getCurrent() + 1);
                refreshListener.onRefresh(refreshLayout);
            }
        });
    }

}
